import { fileURLToPath, URL } from 'node:url';

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import path from 'path';

const pathSrc = path.resolve(__dirname, 'src');

// 自动导入vue中hook reactive ref等
import AutoImport from 'unplugin-auto-import/vite';

//自动导入组件，ui组件 比如说ant-design-vue  element-plus等
import Components from 'unplugin-vue-components/vite';

//ant-design-vue
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ['vue', 'vue-router'],
      dts: path.resolve(__dirname, 'typings', 'auto-imports.d.ts'), // 指定自动导入函数TS类型声明文件路径
      //ant-design-vue
      resolvers: [
        AntDesignVueResolver({
          importStyle: false, // css in js
        }),
      ],
    }),
    Components({
      dts: path.resolve(__dirname, 'typings', 'components.d.ts'), // 指定自动导入组件TS类型声明文件路径
      //ant-design-vue
      resolvers: [
        AntDesignVueResolver({
          importStyle: false, // css in js
        }),
      ],
    }),
  ],
  resolve: {
    alias: {
      '@': pathSrc,
    },
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true, //less编译时启动js
        modifyVars: {}, //全局背景色等
      },
    },
  },
  server:{
    host:"0.0.0.0",
    proxy:{
      '/farm': {
        target: 'http://163.168.0.110',
      }
    }
  }
});
